Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle insert_table errors #129

Merged
merged 5 commits into from
May 27, 2024
Merged

Handle insert_table errors #129

merged 5 commits into from
May 27, 2024

Conversation

couralex6
Copy link
Contributor

Fix for issue #128

Attempting to resolve the issue of unhandled insert errors with a new dataclass InsertTableErrorResult which can handle the error field.

This is most likely not the most elegant way to handle this. I'm open to suggestions :)

@couralex6 couralex6 marked this pull request as draft May 18, 2024 00:46
@bh2smith
Copy link
Collaborator

bh2smith commented May 18, 2024

I like the solution although it doesn't quite follow the pattern we're using everywhere else. If you check the api/execution.py file you'll see this common pattern of try catch key error and then raise of dune error. Realistically we should improve the error classifications, but it might be good to try to follow the similar pattern for now so we can find all the things that need changing after improvements have been made.

I would also prefer to raise here instead of returning something that needs to be matched on. At least until the whole library is working that way.

Copy link
Collaborator

@bh2smith bh2smith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please throw the error or adopt the pattern we use in other places. At least till it's all uniform.

@couralex6
Copy link
Contributor Author

@bh2smith throwing a DuneError when insert failed. I'm using DuneError, but we could also create a new Error type for the tables endpoint. lmk what you think

@couralex6 couralex6 marked this pull request as ready for review May 24, 2024 18:10
@bh2smith
Copy link
Collaborator

Looks good for now! I think improving error handling as a whole could be reserved for a follow up PR. let's get this in for now and address that separately. Let me know if you're happy with this and we can get it released.

Copy link
Collaborator

@RichardKeo RichardKeo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving because this is definitely an improvement and probably ok for now, however, I think this isn't happening in the correct place.

Ideally, we should check the HTTP status code after making a call to the API and handle the response accordingly. When we get a 4XX or 5XX, we could raise an error with details about it rather than letting the response flow as if it was successful.

Copy link
Contributor

@waddahAldrobi waddahAldrobi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with the comments above

@bh2smith bh2smith merged commit ed3836d into main May 27, 2024
3 checks passed
@bh2smith bh2smith deleted the Insert_result_dataclass branch November 12, 2024 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants